﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace NtRuirun.Mes.Migrations
{
    /// <inheritdoc />
    public partial class init : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterDatabase()
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Wms_Material",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(128)", maxLength: 128, nullable: false, comment: "编号", collation: "ascii_general_ci"),
                    Code = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: false, comment: "物料编码")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true, comment: "物料名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Type = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true, comment: "物料类别")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PerUnit = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true, comment: "物料规格")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Wms_Material", x => x.Id);
                },
                comment: "物料信息信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Wms_Warehouse",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(128)", maxLength: 128, nullable: false, comment: "编号", collation: "ascii_general_ci"),
                    Name = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: false, comment: "库位名称")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Desc = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true, comment: "库位备注描述")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    TreePathString = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true, comment: "节点树形路径")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ParentId = table.Column<Guid>(type: "char(128)", nullable: true, comment: "父编号", collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Wms_Warehouse", x => x.Id);
                    table.ForeignKey(
                        name: "FK_WarehouseEntity_ParentId",
                        column: x => x.ParentId,
                        principalTable: "Wms_Warehouse",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                },
                comment: "库位信息信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Wms_Warehouse_ParentId",
                table: "Wms_Warehouse",
                column: "ParentId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Wms_Material");

            migrationBuilder.DropTable(
                name: "Wms_Warehouse");
        }
    }
}
